<!--
 * @Author: hucc
 * @Date: 2021-10-08 18:40:48
 * @LastEditors: hucc
 * @LastEditTime: 2021-10-10 19:02:12
 * @Description: 
-->
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.bootcdn.net/ajax/libs/vue/2.6.13/vue.js"></script>
    <style>
        /* .box {
            background-color: gold;
        } */
    </style>
</head>

<body>
    <div id="app">
        <button :style="isActive=='按钮1'?style:''" @click="clickHandler">按钮1</button>
        <button :style="isActive=='按钮2'?style:''" @click="clickHandler">按钮2</button>
        <button :style="isActive=='按钮3'?style:''" @click="clickHandler">按钮3</button>
        <button :style="isActive=='按钮4'?style:''" @click="clickHandler">按钮4</button>
    </div>
</body>
<script>
    let vm = new Vue({
        el: '#app',
        data: {
            isActive: '',
            style: {
                backgroundColor: 'pink',
            }
        },
        methods: {
            clickHandler() {
                this.isActive = event.target.innerText
            }
        },
    })
</script>

</html>